<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="description" content="">
        <meta name="author" content="">

        <title>后台</title>

        <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

        <!-- Bootstrap core CSS -->
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
        <link rel="stylesheet" href="__PUBLIC__/js/jquery-upload/css/jquery.fileupload.css" />
        <link rel="stylesheet" href="__PUBLIC__/js/jquery-upload/css/jquery.fileupload-ui.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-datetimepicker.css" />
        <link rel="stylesheet" href="__PUBLIC__/js/bootstrapvalidator/css/bootstrapValidator.min.css" />
    </head>

    <body>

        <include file="Common/topNav" />
        <div class="container-fluid">
            <div class="row">
                <include file="Common/leftMenu" />
                <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                    <!--标题头-->
                    <div class="cont-title clearfix">
                        <div class="title">团队信息</div>
                        <div class="btn-group">
                            <button type="button" onclick="javascript:window.history.back();" class="btn btn2">返回</button>
                        </div>
                    </div>

                    <div class="yy-box">
                        <div class="yy-l">
                            <input id="fileupload" type="file" name="files" multiple style="display: none;">
                            <form id="teamDetail">
                                <input type="hidden" name="id" value="{$data.id}" />
                                <div class="imgbox">
                                    <img class="logo" id="teamLogo" src="{:$data['teamLogo']['attachment'] ? '__ROOT__'.$data['teamLogo']['attachment'] : '__PUBLIC__/images/avatar.png'}" alt="{$data.team_name}" />
                                    <input type="hidden" name="teamLogoId" value="{$data.teamLogo.id}" id="teamLogoId" />
                                    <input type="hidden" name="teamLogoChange" value="false" id="teamLogoChange" />
                                    <p class="name">{$data.team_name}</p>
                                </div>
                                <div class="yy-form">
                                    <div class="form-group">
                                        <label>团队</label>
                                        <input type="text" class="form-control " name="team_name" value="{$data.team_name}" placeholder="如：锦创科技">
                                    </div>
                                    <div class="form-group">
                                        <label>入驻时间:</label>
                                        <div class='input-group date' id='settledTime'>
                                            <input type='text' value="{$data['enter_time'] ? $data.enter_time|date='Y-m-d',### : ''}" name="enter_time" class="form-control datetimepicker" data-date-format="yyyy-mm-dd" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-calendar"></span></span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label>离开时间:</label>
                                        <div class='input-group date' id='leaveTime'>
                                            <input type='text' value="{$data['leave_time'] ? $data.leave_time|date='Y-m-d',### : ''}" name="leave_time" class="form-control datetimepicker" data-date-format="yyyy-mm-dd" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-calendar"></span></span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label>人数</label>
                                        <input type="text" class="form-control "  value="{$data.manager|count}" placeholder="" disabled>
                                    </div>
                                    <div class="form-group">
                                        <label>联系人</label>
                                        <input type="text" class="form-control " name="contacts" value="{$data.contacts}"  placeholder="">
                                    </div>
                                    <div class="form-group">
                                        <label>联系方式</label>
                                        <input type="text" class="form-control " name="" value="{$data.contacts_tel}" placeholder="如：15788888888">
                                    </div>
                                    <button type="button" id="saveTeamDetail" class="btn" style="margin-top: 24px;">保存</button>
                                </div>
                            </form>
                        </div>
                        <div class="yy-r yy-tab">
                            <div class="tabbox clearfix">
                                <div class="tab-item active">工商信息</div>
                                <div class="tab-item">项目信息</div>
                                <div class="tab-item">融资信息</div>
                                <if condition="$show_team_resource">
                                    <div class="tab-item">资源配置</div>
                                </if>
<!--                                <div class="tab-item">运营信息</div>
                                <div class="tab-item">财务信息</div>
                                <div class="tab-item">人力资源</div>-->
                            </div>
                            <!--工商信息-->
                            <div class="tab-pane active">
                                <form id="teamCompanyDetail">
                                    <input type="hidden" name="id" value="{$data.company.id}" />
                                    <div class="yy-form">
                                        <div class="form-group">
                                            <label>注册号/统一社会信用代码</label>
                                            <input type="text" class="form-control" name="registration_mark" value="{$data.company.registration_mark}" >
                                        </div>
                                        <div class="form-group">
                                            <label>公司名称</label>
                                            <input type="text" class="form-control" name="name" value="{$data.company.name}">
                                        </div>
                                        <div class="form-group">
                                            <label>法人代表</label>
                                            <input type="text" class="form-control" name="legal_person" value="{$data.company.legal_person}">
                                        </div>
                                        <div class="form-group2 clearfix">
                                            <div class="form-group">
                                                <label>注册时间</label>
                                                <div class='input-group date' id='datetimepicker'>
                                                    <input type='text' value="{$data['company']['registration_time'] ? $data.company.registration_time|date='Y-m-d',### : ''}" name="registration_time" class="form-control datetimepicker" data-date-format="yyyy-mm-dd" />
                                                    <span class="input-group-addon">
                                                        <span class="glyphicon glyphicon-calendar"></span></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label>注册资本</label>
                                                <div class="input-group">
                                                    <input type="text" class="form-control" name="registration_capital" value="{$data.company.registration_capital}" >
                                                    <div class="input-group-addon">元</div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label>注册地址</label>
                                            <input type="text" class="form-control" name="registration_address" value="{$data.company.registration_address}" >
                                        </div>
                                        <div class="form-group">
                                            <if condition="$data['companyLogo']">
                                                <label>营业执照<span class="tag-state" style='background-color: greenyellow;'>已上传</span></label>
                                                <div id="uploadCompnayLogo">{$data.companyLogo.filename}</div>
                                                <else />
                                                <label>营业执照<span class="tag-state">未上传</span></label>
                                                <div id="uploadCompnayLogo">未选择任何文件</div>
                                            </if>
                                            <input id="companyLogoUpdate" type="file" name="files" multiple style="display: none;">

                                            <input type="hidden" value="false" id="companyLogoChange" name="companyLogoChange" />	
                                            <input type="hidden" value="{$data.companyLogo.id}" id="companyLogoId" name="companyLogoId" />	
                                        </div>
                                        <div class="form-group">
                                            <label>经营范围</label>
                                            <textarea rows="4" class="form-control" name="scope" cols="200" placeholder="200字以内">{$data.company.scope}</textarea>
                                        </div>
                                    </div>
                                    <button type="button" id="saveTeamCompany" class="btn">保存</button>
                                </form>
                            </div>
                            <!--项目信息-->
                            <div class="tab-pane">
                                <form id="teamProjectDetail">
                                    <input type='hidden' name='id' value='{$data.team_project.id}' />
                                    <div class="yy-form">
                                        <div class="form-group">
                                            <label>项目名称</label>
                                            <input type="text" class="form-control" name="name" value="{$data.team_project.name}">
                                        </div>
                                        <div class="checkbox">
                                            <label>
                                                <input <if condition="$data['team_project']['is_public'] eq 1" >checked="checked"</if> value="1" name="is_public" type="checkbox"> 公开项目
                                            </label>
                                        </div>
                                        <div class="form-group">
                                            <label>项目简介</label>
                                            <textarea rows="4" class="form-control" name="description" cols="200" placeholder="200字以内">{$data.team_project.description}</textarea>
                                        </div>
                                        <div class="form-group">

                                            <if condition="$data['projectLogo']">
                                                <label>商业计划书<span class="tag-state" style='background-color: greenyellow;'>已上传</span></label>
                                                <div id="uploadProjectLogo">{$data.projectLogo.filename}</div>
                                                <else />
                                                <label>营业执照<span class="tag-state">未上传</span></label>
                                                <div id="uploadProjectLogo">未选择任何文件</div>
                                            </if>
                                            <input id="projectLogoUpdate" type="file" name="files" multiple style="display: none;">

                                            <input type="hidden" value="false" id="projectLogoChange" name="projectLogoChange" />	
                                            <input type="hidden" value="{$data.projectLogo.id}" id="projectLogoId" name="projectLogoId" />   
                                        </div>
                                        <div class="form-group">
                                            <label>所属行业</label>
                                            <input type="text" class="form-control" name="industry" value="{$data.team_project.industry}" >
                                        </div>
                                        <div class="form-group">
                                            <label>安卓-应用宝包名</label>
                                            <input type="text" class="form-control" name="app_name_android" value="{$data.team_project.app_name_android}" >
                                        </div>
                                        <div class="form-group">
                                            <label>PC-官网地址</label>
                                            <input type="text" class="form-control" name="website" value="{$data.team_project.website}">
                                        </div>
                                        <div class="form-group">
                                            <label>微信公众号</label>
                                            <input type="text" class="form-control" name="weixin" value="{$data.team_project.weixin}" >
                                        </div>
                                        <div class="form-group">
                                            <label>其他</label>
                                            <textarea rows="4" class="form-control" name="remark" cols="200" placeholder="200字以内">{$data.team_project.remark}</textarea>
                                        </div>
                                    </div>
                                    <button type="button" id="saveTeamProjectDetail" class="btn">保存</button>
                                </form>
                            </div>
                            <!--融资信息-->
                            <div class="tab-pane">
                                <div class="clearfix">
                                    <div class="col-sm-6">
                                        <ul class="timeline">
                                            <li class="tl-item">
                                                <div class="tl-wrap tl-wrap2">
                                                    <div class="tl-content">
                                                        <button type="button" id="addFinancing" class="btn btn-add2">新增融资</button>
                                                    </div>
                                                </div>
                                            </li>
                                            <volist name="data['team_financing']" id="tf">
                                                <li class="tl-item">
                                                    <div class="tl-wrap">
                                                        <div class="tl-content tl-cont2 col-xs-12">
                                                            <span class="arrow-left"></span>
                                                            <div class="title">{$tf.financing_no} - {$tf.amount|number_format=2} 元<a class="btn-close"></a></div>
                                                            <div class="cont">
                                                                <div>融资时间：{$tf.investment_time|date='Y-m-d',###}</div>
                                                                <div>融资占比：{$tf.ratio}%</div>
                                                                <div>投资人：{$tf.investor}</div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </li>
                                            </volist>
                                        </ul>
                                    </div>
                                    <div class="col-sm-6">
                                        <form id="teamFinancingPlanForm">
                                            <input type="hidden" name="id" value="{$data.financing_plan.id}" />
                                            <input type="hidden" name="team_id" value="{$data.id}" />
                                            <div class="yy-form2">
                                                <div class="form-group">
                                                    <label>下一轮融资计划</label>
                                                    <input type="text" class="form-control" name="name" value="{$data.financing_plan.name}">
                                                </div>
                                                <div class="form-group">
                                                    <label>计划金额(元)</label>
                                                    <input type="text" class="form-control" name="amount" value="{$data.financing_plan.amount}">
                                                </div>
                                                <div class="form-group">
                                                    <label>预计出让股权比例(%)</label>
                                                    <input type="text" name="ratio" class="form-control" value="{$data.financing_plan.ratio}">
                                                </div>
                                                <div class="form-group">
                                                    <label>备注</label>
                                                    <input type="text" class="form-control" name="remark" value="{$data.financing_plan.remark}">
                                                </div>
                                                <div class="checkbox">
                                                    <label>
                                                        <input <if condition="$data['financing_plan']['is_seek'] eq 1">checked="checked"</if> name="is_seek" value="1" type="checkbox"> 寻求融资
                                                    </label>
                                                </div>
                                            </div>
                                            <button type="button" id="saveFinancingPlanBtn" class="btn">保存</button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <if condition="$show_team_resource">
                                <!--资源配置-->
                                <include file="team_resource" />
                            </if>
                            <!--运营信息-->
<!--                            <div class="tab-pane">
                                <form>
                                    <div class="yy-form">
                                        <div class="form-group">
                                            <label>注册户数</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>月交易额</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>日活</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>月活</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn">保存</button>
                                </form>
                            </div>
                            财务信息
                            <div class="tab-pane">
                                <form>
                                    <div class="yy-form">
                                        <div class="form-group">
                                            <label>月收入</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>月费用</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>现金流情况</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>资金消耗率</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn">保存</button>
                                </form>
                            </div>
                            人力资源
                            <div class="tab-pane">
                                <form>
                                    <div class="yy-form">
                                        <div class="form-group">
                                            <label>目前在职人数</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>人员招聘主要渠道</label>
                                            <select class="form-control">
                                                <option>选择渠道</option>
                                                <option>2</option>
                                                <option>3</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label>未来3-6个月计划扩张人数</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="">
                                        </div>
                                        <div class="form-group">
                                            <label>急需岗位</label>
                                            <input type="text" class="form-control" name="" value="" placeholder="最多8个，以#号分隔">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn">保存</button>
                                </form>
                            </div>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <include file="Common/modalHtmls" />
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-upload/js/vendor/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-upload/js/jquery.fileupload.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-upload/js/jquery.fileupload-ui.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-upload/js/jquery.iframe-transport.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-upload/js/jquery.fileupload-process.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/teamDetail.js"></script>
    <script type="text/javascript">
        //tab切换
        var root = "__ROOT__";
        var teamId = "{$data.id}";
        $('.tabbox .tab-item').click(function () {
            $(this).addClass('active').siblings().removeClass('active');
            $('.tab-pane').eq($(this).index()).addClass('active').siblings().removeClass('active');
        });

        $("#teamLogo").click(function () {
            $('#fileupload').click();
        });

        $("#uploadCompnayLogo").click(function () {
            $("#companyLogoUpdate").click();
        });

        $("#uploadProjectLogo").click(function () {
            $("#projectLogoUpdate").click();
        });
        $('#fileupload').fileupload({
            url: "{:U('Admin/Upload/index')}",
            dataType: "json",
            formData: {type: "teamLogo"},
            autoUpload: true,
            done: function (e, data) {
                var files = data.result;
                var file = files[0];
                console.log(file);
                $("#teamLogo").attr("src", root + file.filePath);
                $("#teamLogoId").val(file.attachement_id);
                $("#teamLogoChange").val(true);
            }
        });

        $("#companyLogoUpdate").fileupload({
            url: "{:U('Admin/Upload/index')}",
            dataType: "json",
            formData: {type: "company"},
            autoUpload: true,
            done: function (e, data) {
                var files = data.result;
                var file = files[0];
                console.log(file);
                $("#uploadCompnayLogo").html(file.name);
                $("#companyLogoId").val(file.attachement_id);
                $("#companyLogoChange").val(true);

            }
        });

        $("#projectLogoUpdate").fileupload({
            url: "{:U('Admin/Upload/index')}",
            dataType: "json",
            formData: {type: "teamProject"},
            autoUpload: true,
            done: function (e, data) {
                var files = data.result;
                var file = files[0];
                console.log(file);
                $("#uploadProjectLogo").html(file.name);
                $("#projectLogoId").val(file.attachement_id);
                $("#projectLogoChange").val(true);

            }
        });

        $('.datetimepicker').datetimepicker({
            format: 'yyyy-mm-dd',
            language: 'ch',
            pickDate: true,
            pickTime: false,
            autoclose: true,
            minView: 2,
            //pickerPosition:"bottom-left"
        });

        $("#saveTeamDetail").click(function () {
            var postUrl = "{:U('Admin/Space/Settled/doSaveTeamDetail')}";
            saveTeamDetail(postUrl, function (data) {
                if (data == true) {
                    common.alert("提示", "团队信息更新成功!", function () {});
                } else if (data.info){
                    common.alert("提示",data.info);
                }
            });
        });

        $("#saveTeamCompany").click(function () {
            if(!validateCompany()){
                return false;
            }
            var postUrl = "{:U('Admin/Space/Settled/doSaveTeamCompanyDetail')}";
            saveTeamCompanyDetail(postUrl, function (data) {
                if (data == true) {
                    common.alert("提示", "团队公司信息更新成功!", function () {});
                } else if (data.info){
                    common.alert("提示",data.info);
                }
            });
        });

        $("#saveTeamProjectDetail").click(function () {
            var postUrl = "{:U('Admin/Space/Settled/doSaveTeamProjectDetail')}";
            saveTeamProjectDetail(postUrl, function (data) {
                if (data == true) {
                    common.alert("提示", "团队项目信息更新成功!", function () {});
                } else if (data.info){
                    common.alert("提示",data.info);
                }
            });
        });
        
        $("#saveFinancingPlanBtn").click(function(){
            if(!validateFinancingPlan()){
                return false;
            }
            var postUrl = "{:U('Admin/Space/Settled/doSaveTeamFinancingPlan')}";
            saveTeamFinancingPlan(postUrl,function(data){
                if (data == true) {
                    common.alert("提示", "团队融资计划更新成功!", function () {});
                } else if (data.info){
                    common.alert("提示",data.info);
                }
            })
        });

        $("#addFinancing").click(function () {
            common.htmlAjax("{:U('Admin/Space/Settled/addFinancing')}?teamId=" + teamId, {teamId: teamId}, function (html) {
                if(common.isJsonString(html)){
                    var error = JSON.parse(html);
                    if (error.info){
                        common.alert("提示",error.info);
                    }
                    return;
                }
                $("#commonModal").html(html).modal('toggle');
            })
        });
        $("#saveTeamResourceDetail").click(function () {
            $.ajax({
                url: "{:U('Admin/Space/Settled/doSaveTeamResource')}",
                type: "post",
                dataType: "json",
                data: $("#teamResourceDetail").serialize(),
                success: function (data) {
                    common.alert("提示",data.msg);
                }
            });
        });

        function validateCompany() {
            $('#teamCompanyDetail').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    //invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    registration_mark: {
                        validators: {
                            notEmpty: {
                                message: '注册号/统一社会信用代码不能为空'
                            }
                        }
                    },
                    name: {
                        validators: {
                            notEmpty: {
                                message: '公司名称不能为空'
                            }
                        }
                    },
                    legal_person: {
                        validators: {
                            notEmpty: {
                                message: '法人代表不能为空'
                            }
                        }
                    },
                    registration_time: {
                        validators: {
                            notEmpty: {
                                message: '注册时间不能为空'
                            }
                        }
                    },
                    registration_capital: {
                        validators: {
                            notEmpty: {
                                message: '注册资本不能为空'
                            },
                            regexp: {
                                regexp: /((^[1-9]+[0-9]*)|^0)(\.\d{0,2})?$/,
                                message: '注册资本必须为数字，最多2位小数'
                            }
                        }
                    },
                    registration_address: {
                        validators: {
                            notEmpty: {
                                message: '注册地址不能为空'
                            }
                        }
                    }
                }
            });
            var data = $('#teamCompanyDetail').data('bootstrapValidator');
            if (data) {
                data.validate();
                if (!data.isValid()) {
                    return false;
                }
            }
            return true;
        }

        function validateFinancingPlan() {
            $('#teamFinancingPlanForm').bootstrapValidator({
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    //invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    name: {
                        validators: {
                            notEmpty: {
                                message: '融资计划名称不能为空'
                            }
                        }
                    },
                    amount: {
                        validators: {
                            notEmpty: {
                                message: '计划融资金额不能为空'
                            },
                            regexp: {
                                regexp: /((^[1-9]+[0-9]*)|^0)(\.\d{0,2})?$/,
                                message: '计划融资金额必须为数字，最多2位小数'
                            }
                        }
                    },
                    ratio: {
                        validators: {
                            notEmpty: {
                                message: '股份比例不能为空'
                            },
                            regexp: {
                                regexp: /((^[1-9]+[0-9]*)|^0)(\.\d{0,2})?$/,
                                message: '股份比例必须为数字，最多2位小数'
                            }
                        }
                    }
                }
            });
            var data = $('#teamFinancingPlanForm').data('bootstrapValidator');
            if (data) {
                data.validate();
                if (!data.isValid()) {
                    return false;
                }
            }
            return true;
        }

    </script>
</body>
</html>
